Skip to content

Conversation

@rolfbjarne
Copy link
Member

This consists of two parts:

  • Add an MSBuild target that lists all the available devices (ComputeAvailableDevices), by returning them in a $(Devices) item group.
  • Add support for the $(Device) property to specify the device or simulator to use.

Regarding the device list, we'll filter the returned list by:

  • Platform (don't return an Apple TV simulator for an iOS app).
  • Minimum OS version (not return an iOS 18.0 device when the app's minimum OS version is 26.0).
  • Only devices that are actually available, as reported by devicectl or simctl.
  • Don't return an arm64 simulator on an x64 machine.
  • RuntimeIdentifier, if specified on the command-line.

References:

Fixes #23995.
Backport of #24279.

…mulators available to run on.

This consists of two parts:

* Add an MSBuild target that lists all the available devices (`ComputeAvailableDevices`), by returning them in a `$(Devices)` item group.
* Add support for the `$(Device)` property to specify the device or simulator to use.

Regarding the device list, we'll filter the returned list by:

* Platform (don't return an Apple TV simulator for an iOS app).
* Minimum OS version (not return an iOS 18.0 device when the app's minimum OS version is 26.0).
* Only devices that are actually available, as reported by `devicectl` or `simctl`.

References:

* dotnet/android#10576
* https://github.com/dotnet/sdk/blob/2b9fc02a265c735f2132e4e3626e94962e48bdf5/documentation/specs/dotnet-run-for-maui.md

Fixes #23995.
@rolfbjarne rolfbjarne requested a review from Copilot January 22, 2026 11:06
@rolfbjarne rolfbjarne changed the title [main] [net11.0] [msbuild/dotnet] Add support for listing the devices and simulators available to run on. [msbuild/dotnet] Add support for listing the devices and simulators available to run on. Jan 22, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for listing available iOS and tvOS devices and simulators that can be used with dotnet run. It implements the ComputeAvailableDevices MSBuild target and adds support for the $(Device) property to specify which device or simulator to use when running applications.

Changes:

  • Adds new GetAvailableDevices MSBuild task that queries devicectl and simctl for available devices/simulators
  • Introduces JsonExtensions utility class for parsing JSON output from Apple command-line tools
  • Reorganizes targets into separate Mobile and Desktop target files for better modularity
  • Updates documentation to describe the new Device property and ComputeAvailableDevices target

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/common/JsonExtensions.cs New JSON helper extension methods for parsing devicectl/simctl output
msbuild/Xamarin.MacDev.Tasks/Tasks/GetAvailableDevices.cs Main implementation that queries and filters devices based on platform, OS version, and runtime identifier
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GetAvailableDevicesTest.cs Comprehensive unit tests with test JSON data
dotnet/targets/Microsoft.Sdk.Mobile.targets Extracted mobile-specific targets including the new ComputeAvailableDevices target
dotnet/targets/Microsoft.Sdk.Desktop.targets Extracted desktop-specific targets for macOS/MacCatalyst
dotnet/targets/Xamarin.Shared.Sdk.targets Refactored to import mobile/desktop targets conditionally
msbuild/Xamarin.MacDev.Tasks/Tasks/GetMlaunchArguments.cs Refactored product family string constants for consistency
docs/building-apps/build-targets.md Documents the new ComputeAvailableDevices target
docs/building-apps/build-properties.md Documents the new Device property
tests/dotnet/MultiFrameworkApp/* New multi-framework test application
tests/common/shared-dotnet.mk Updated to use Device property instead of _DeviceName
msbuild/Xamarin.Shared/Xamarin.Shared.targets Moved _AppBundleManifestPath property definition
msbuild/Xamarin.MacDev.Tasks/Xamarin.MacDev.Tasks.csproj Added JsonExtensions.cs to project
dotnet/Makefile Added new target files to build

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

<_RelativeMlaunchPath Condition="'$(_RelativeMlaunchPath)' == ''">$(RelativeMlaunchPath)</_RelativeMlaunchPath>

<!-- Try to keep _DeviceName working for a while yet -->
<Device Condition="'$(Device)' == ''">$(_DeviceName)</Device>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@rolfbjarne rolfbjarne enabled auto-merge (squash) January 22, 2026 17:37
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #0a2ab67] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 0a2ab671784564514ffd10d45c445dd8a0b974fb [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #0a2ab67] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 0a2ab671784564514ffd10d45c445dd8a0b974fb [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 0a2ab671784564514ffd10d45c445dd8a0b974fb [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #0a2ab67] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 0a2ab671784564514ffd10d45c445dd8a0b974fb [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #0a2ab67] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 0a2ab671784564514ffd10d45c445dd8a0b974fb [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #0a2ab67] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 0a2ab671784564514ffd10d45c445dd8a0b974fb [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #0a2ab67] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 0a2ab671784564514ffd10d45c445dd8a0b974fb [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #0a2ab67] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: 0a2ab671784564514ffd10d45c445dd8a0b974fb [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #0a2ab67] Tests on macOS arm64 - Mac Tahoe (26) passed 💻

All tests on macOS arm64 - Mac Tahoe (26) passed.

Pipeline on Agent
Hash: 0a2ab671784564514ffd10d45c445dd8a0b974fb [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #0a2ab67] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 117 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 9 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 0a2ab671784564514ffd10d45c445dd8a0b974fb [PR build]

@rolfbjarne rolfbjarne merged commit 61fbbe9 into main Jan 23, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve device selection when using 'dotnet run'

4 participants